package com.qd.p2p.web.action.notify.loan;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Qualifier;

import com.qd.p2p.web.action.notify.TradeNotifyBaseAction;
import com.qd.p2p.web.action.notify.TradeNotifyValueEvent;
import com.qdlc.p2p.biz.service.CollectPayService;
import com.qdlc.p2p.common.constant.NotifyUrl;

/**
 * 满标复审-放款【代付】 -回调
 *
 * @author zhaokaiju
 */
public class NotifyPayAction extends TradeNotifyBaseAction {

    /** 业务名 */
    private final static String BUSINESS_NAME = "满标复审";

    /** 业务处理名 */
    private final static String PROCESS_NAME = "代付";

	@Resource
	@Qualifier("borrowFullVerifyPayService")
	private CollectPayService borrowFullVerifyPayService;

    /**
     * 满标复审-放款【代付】 回调处理
     */
    @Override
    @Action(value = NotifyUrl.BORROW_LOAN_NOTIFY_PAY_URL)
    public void doAction() {
        actionHandle();
    }

    @Override
    public String getBusinessName() {
        return BUSINESS_NAME;
    }

    @Override
    public String getProcessName() {
        return PROCESS_NAME;
    }

    /**
     * 完成状态 业务处理
     */
    @Override
    public void finishHandle(TradeNotifyValueEvent event) {
		borrowFullVerifyPayService.tradeFinish(event.getTppTradeLog(), event.getDepositStatus(),
				event.getDepositAmount());
    }

    /**
     * 成功状态 业务处理
     */
    @Override
    public void successHandle(TradeNotifyValueEvent event) {
		borrowFullVerifyPayService.tradeSuccess(event.getTppTradeLog(), event.getDepositStatus());
    }

    /**
     * 失败状态 业务处理
     */
    @Override
    public void failHandle(TradeNotifyValueEvent event) {
		borrowFullVerifyPayService.tradeFail(event.getTppTradeLog(), event.getDepositStatus());
    }
}
